const app = getApp()
import { currentDates } from '../../utils/util'
Page({
  data: {
    imgurl:app.globalData.imgurl
  },

  onLoad (options) {this._getData()},
  _tolink({currentTarget:{ dataset:{sid}}}) {
    wx.navigateTo({
      url: '/pages/storeIntroduction/storeIntroduction?s_id='+sid,
    })
  },
  _toDetail({currentTarget:{ dataset:{oid}}}) {
    wx.navigateTo({
      url: '/pages/feedbackDetail/feedbackDetail?o_id='+oid,
    })
  },
  async _getData() {
    let {code ,data} = await wx.requestAsync({
      url: '/feedback',
      data: { page:1, },
    })
    if (code == 0) {
      let list = data.map(item => {
      item.avatar = this.data.imgurl + item.avatar
      item.pre_at = currentDates(item.pre_at*1000)
      item.create_at =currentDates(item.create_at*1000,1)
      return item
      })
      this.setData({
        list
      })
    }
  },
  onShareAppMessage ({target:{dataset:{info:{avatar,shop_name,o_id}}}}) {
    return {
      title:shop_name,
      path: '/pages/feedbackDetail/feedbackDetail?o_id='+o_id,
      imageUrl: avatar,  //用户分享出去的自定义图片大小为5:4,
      success: function (res) {
	   // 转发成功
	        wx.showToast({
	          title: "分享成功",
	          icon: 'success',
	          duration: 2000
	        })
       },
      fail: function (res) {
        // 分享失败
      },
    }
  },

})
